<template>
  <div id="loginindex">
    <div class="login_wrap">
      <img width="100%" height="100%" src="/../../static/img/login.jpg" class="bg_img">
      <div class="login_main">
        <img width="100%" height="100%" opacity="0.2" src="/../../static/img/login.jpg">
        <div class="login_text">
          <div class="login_left">
            <div>
              <div class="left private_left">
                <router-link to="/">
                  <svg class="icon login_icon" aria-hidden="true">
                    <use xlink:href="#icon-icon_xiangji"></use>
                  </svg>
                </router-link>
              </div>
              <p>Welcome to login</p>
            </div>
          </div>
          <div class="login_right">
            <p class="right_text">登录</p>
            <div>
              <i class="iconfont icon-yonghuming"></i>
              <input class="login_input" type="text" v-model="username">
            </div>
            <div>
              <i class="iconfont icon-mima1"></i>
              <input class="login_input" type="password" v-model="password">
            </div>
            <div class="right_text">
              <button @click="handerLogin">sign in</button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "LoginIndex",
  data() {
    return {
      username: "",
      password: ""
    };
  },
  methods: {
    handerLogin() {
      let jsons = {
        username: this.username,
        password: this.password
      };
      axios.post("api/user", jsons).then(res => {
        console.log(res);
        if (res.data.data) {
          console.log("成功");
          sessionStorage.userName = this.username;
          console.log(this.username);
          this.$router.push("/PrivateIndex");
        } else {
          console.log("失败");
          this.$router.push("/LoginFail");
        }
      });
    },

    getUsersURl() {}
  },
  mounted() {}
};
</script>

<style scoped>
.bg_img {
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  filter: blur(2px);
  -webkit-filter: blur(2px); /* Chrome, Opera */
  -moz-filter: blur(2px);
  -ms-filter: blur(2px);
}
.login_main {
  position: absolute;
  width: 800px;
  right: 0;
  top: 25%;
  left: 0;
  bottom: 25%;
  margin: auto;
  border: 1px solid rgb(250, 250, 250);
  min-height: 230px;
}
.login_main img {
  opacity: 0.5;
}
.login_icon {
  width: 90%;
  margin-left: 75px;
}
.login_left {
  display: flex;
  position: absolute;
  top: 44%;
  left: 5%;
  color: rgb(250, 250, 250);
  font-size: 2.5em;
}
.login_left {
  position: absolute;
  color: rgb(250, 250, 250);
  font-size: 2.5em;
  width: 335px;
  height: 210px;
  left: -309px;
  right: 0;
  top: 74px;
  bottom: 0;
  margin: auto;
}
.login_right {
  position: absolute;
  color: rgb(250, 250, 250);
  font-size: 2.5em;
  padding-left: 55px;
  margin-left: 150px;
  border-left: 2px solid rgb(250, 250, 250);
  width: 335px;
  height: 210px;
  left: 261px;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
}
.right_text {
  text-align: center;
}
.right_text button,
.login_input {
  background-color: rgba(0, 0, 0, 0);
  border: 1px solid rgb(250, 250, 250);
  border-radius: 5px;
  padding: 5px 10px;
  margin: 10px;
  outline: none;
  color: rgb(250, 250, 250);
  font-size: 50%;
}
</style>